from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from time import sleep
services = Service('chromedriver.exe')
driver = webdriver.Chrome(service=services)
driver.get("https://www.baidu.com/")
# 输入内容
driver.find_element(By.NAME,"wd").send_keys("侯雯中")
# 点击搜索按钮
driver.find_element(By.ID,"su").click()
# 滚动条下拉
sleep(3)
win1 = 'window.scrollBy(0,1000)' # Y轴向下500像素
win2 = 'window.scrollBy(0,-500)' # Y轴向上500像素
win3 = "window.scrollBy(500,0)" # X向右500像素
win4 = "window.scrollBy(-500,0)" # X向左500像素
driver.execute_script(win1)
sleep(2)
driver.execute_script(win2)
sleep(2)
driver.execute_script(win3)
sleep(2)
driver.execute_script(win4)
sleep(100)

